package com.nstc.sftpExchange.config.sftp;

import lombok.extern.slf4j.Slf4j;


@Slf4j
public class ConnectionHandler<T> {
    //引用计数
    private int referenceCount = 0;

    private T conn = null;


    public ConnectionHandler(T conn) {
        this.conn = conn;
    }


    public T getConn() {
        return conn;
    }


    public int requested(String name) {
        referenceCount++;
        log.info("name：{}，referenceCount：{}", name, referenceCount);
        return referenceCount;
    }


    public int released() {
        referenceCount--;
        return referenceCount;
    }
}